package com.linux.huhx.concurreny;

public class ConditionTest1 {
    public static void main(String[] args) throws Exception {
        final BoundedBuffer boundedBuffer = new BoundedBuffer();
        new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 20; i++) {
                    try {
                        boundedBuffer.take();
                        System.out.print("t" + i + " ");
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 20; i++) {
                    try {
                        boundedBuffer.put("string" + i);
                        System.out.print("p" + i + " ");
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }).start();
    }
}
